<?php
include_once("../../service/productService.php");

$imgPaths = $_POST["imgPaths"];
$proId = $_POST["id"];
$isSuccess = true;
$arrayOfImagePath = preg_split("/,/", $imgPaths);

$imageList = findImagesOfProduct($proId);
$insertedImages = array();
while($row = ConnectionManager::getInstance()->fetch($imageList)){
    $insertedImages[] = array("name" => $row["IMG_PATH"]);
}

foreach($arrayOfImagePath as $each){
	// check if an image was instert into database or not
	$isExisted = false;
	foreach($insertedImages as $aImage){
		if($each == $aImage["name"]) {
			$isExisted = true;
			break;
		}
	}
	
	if(!$isExisted) creatNormalImage($proId, $each);
}
?>